#!/usr/bin/perl
use strict;
use warnings;
use threads;
use threads::shared;

print "Starting main program\n";

my @threads;
for (my $count = 1; $count <=10; $count++) {
  my $t = threads->new(\&sub1, $count);
  push(@threads, $t);
}
foreach (@threads) {
  my $num = $_->join;
  print "Done with $num\n";
}

sub sub1 {
  my $num = shift;
  print "Started thread $num\n";
  sleep $num;
  print "done with thread $num\n";
  return $num;
}
